package com.smartao.base.selecttype;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.smartao.base.Constant;
import com.smartao.base.init.InitializeServiceOrder;
import com.smartao.base.module.Module;
import com.smartao.base.module.ModuleService;
import com.smartao.core.init.AbstractDataInitializeService;

@Service
public class SelecttypeInitializeService extends AbstractDataInitializeService{

	private int order = InitializeServiceOrder.INIT_ORDER_SELECTTYPE;
	
	@Autowired
	private SelecttypeService selecttypeService;
	@Autowired
	private ModuleService moduleService;
	
	@Override
	public int getOrder() {
		return order;
	}

	@Override
	public void initData() throws Exception {
		if(selecttypeService.findByCode(Constant.SELECTTYPE_DEPARTMENT_DIMENSION)!=null){
			return;
		}
		Module module = moduleService.findByModuleKey(Constant.MODULE_BASE);
		Selecttype selecttype = new Selecttype();
		selecttype.setModule(module);
		selecttype.setName("组织维度");
		selecttype.setCode(Constant.SELECTTYPE_DEPARTMENT_DIMENSION);
		selecttypeService.save(selecttype);
		
		Selecttype s1 = new Selecttype();
		s1.setModule(module);
		s1.setName("岗位级别");
		s1.setCode(Constant.SELECTTYPE_POSITION_RANK);
		selecttypeService.save(s1);
		
		Selecttype s2 = new Selecttype();
		s2.setModule(module);
		s2.setName("角色类型");
		s2.setCode(Constant.SELECTTYPE_ROLE_TYPE);
		selecttypeService.save(s2);
	}

}
